package com.wenan.ui.controls.standard
{
	import flash.events.MouseEvent;
	
	import spark.components.Label;
	
	public class LinkLabel extends Label
	{
		private var _customColor:String;
		private var _hoverColor:String = "#FF0000";
		private var _data:Object = null;

		public function LinkLabel()
		{
			super();
			mouseChildren = false;
			buttonMode = true;
			addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
			addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
		}

		public function get customColor():String
		{
			return _customColor;
		}

		public function set customColor(value:String):void
		{
			_customColor = value;
			setStyle("color", _customColor);	
		}

		public function get hoverColor():String
		{
			return _hoverColor;
		}

		public function set hoverColor(value:String):void
		{
			_hoverColor = value;
		}
		
		public function get linkable():Boolean
		{
			return useHandCursor;
		}
		
		public function set linkable(value:Boolean):void
		{
			useHandCursor = value;
			if (!value)
			{
				setStyle("alpha", "0.5");	
				setStyle("color", _customColor);	
			}
		}
		
		public function get data():Object
		{
			return _data;
		}
		
		public function set data(value:Object):void
		{
			_data = value;
		}
		
		private function mouseOverHandler(event:MouseEvent):void
		{
			if (linkable)
			{
				setStyle("color", _hoverColor);	
			}
		}
		
		
		private function mouseOutHandler(event:MouseEvent):void
		{
			if (linkable)
			{
				setStyle("color", _customColor);
			}
		}
		
		public function set defaultColor(color:String):void
		{
			_customColor = color;
			setStyle("color", color);		
		}
	}
}